/**
 * Created by Administrator on 2017/12/4.
 */
import React, {PureComponent} from 'react';
import {Table, Alert,Select, Badge, Switch, Icon,Button, InputNumber, Tooltip, Popconfirm} from 'antd';
import styles from './index.less';
import {powerControl} from '../../utils/powerControl';
const Option = Select.Option;
const AuthButton = powerControl(Button);

export default class DistributorTable extends PureComponent{
    handleTableChange = (pagination, filters, sorter) => {
        this.props.onChange(pagination, filters, sorter);
    }
    handleChange=(e, flag)=>{
        this.props.handleChange(e,flag);
    }

    render(){
        const {data: {list, pagination}, loading} = this.props;
        const columns = [
            {
                title: '申请编号',
                dataIndex: 'task_id',
                key: 'task_id',
            }, {
                title: '会员编号',
                dataIndex: 'user_id',
                key: 'user_id',
            }, {
                title:'会员昵称',
                dataIndex:'nick_name',
                key:'nick_name'
            }, {
                title: '申请类型',
                dataIndex: 'task_type',
                key: 'task_type',
            }, {
                title: '申请时间',
                dataIndex: 'create_time',
                key: 'create_time',
            }, {
                title:'申请店铺名',
                dataIndex:'seller_name',
                key:'seller_name'
            },{
                title:'分销商名称',
                dataIndex:'user_name',
                key:'user_name'
            },{
                title:'电话',
                dataIndex:'phone',
                key:'phone',
            },{
                title: '操作',
                render: (text, record) => {
                    return (

                        <p>
                            <AuthButton ghost   className={styles.btn} size="small"  auth="distributor.pass"    onClick={() => this.handleChange(record, 1)}>通过</AuthButton>
                            <span className={styles.splitLine}/>
                            <AuthButton ghost    className={styles.btn} size="small"  auth="distributor.unpass"  onClick={() => this.handleChange(record, 2)}>不通过</AuthButton>
                        </p>
                    )
                }
            }
        ];
        const paginationProps = {
            showSizeChanger: true,
            showQuickJumper: true,
            ...pagination,
        };
        return (
            <div className={styles.standardTable}>
                <Table
                    loading={loading}
                    rowKey={record => record.TASK_ID}
                    dataSource={list}
                    columns={columns}
                    pagination={paginationProps}
                    onChange={this.handleTableChange}
                />
            </div>
        );
    }
}